
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <thread>

using namespace std;

// 全局共享变量
int counter = 0;

void increment() {
    for (int i = 0; i < 100000; ++i) {
        ++counter;  // 数据竞争！
    }
}

int main() {
    std::thread t1(increment);
    std::thread t2(increment);
    
    t1.join();
    t2.join();
    
    // 结果不确定，可能小于200000
    std::cout << "Final counter: " << counter << std::endl;
    return 0;
}